package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.ro.SystemMessageRO;
import com.dc.entity.vo.SystemMessageVO;
import com.dc.service.SystemMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "系统消息通知")
@RestController
@RequestMapping(value = "/systemMessage", produces = "application/json")
public class SystemMessageController {

    @Resource
    SystemMessageService SystemMessageService;

    @ApiOperation(value = "系统消息通知列表（后台）", notes = "系统消息通知列表")
    @RequestMapping(value = "/selectSystemMessage", method = RequestMethod.POST)
    public ResponseResultVO<SystemMessageVO> selectSystemMessage(@RequestBody(required = false) SystemMessageRO systemMessage) {
        return SystemMessageService.selectSystemMessage(systemMessage);
    }

    @Log(title = "系统消息通知", businessDesc = "新增消息")
    @ApiOperation(value = "新增消息（后台）", notes = "新增消息")
    @RequestMapping(value = "/insertSystemMessage", method = RequestMethod.POST)
    public ResponseResultVO<SystemMessageVO> insertSystemMessage(@RequestBody(required = false) SystemMessageRO systemMessage) {
        return SystemMessageService.insertSystemMessage(systemMessage);
    }

    @Log(title = "系统消息通知", businessDesc = "增加群发消息")
    @ApiOperation(value = "增加群发消息（后台）", notes = "增加群发消息")
    @RequestMapping(value = "/insertBatchSystemMessage", method = RequestMethod.POST)
    public ResponseResultVO insertBatchSystemMessage(@RequestBody SystemMessageRO systemMessage) {
        return SystemMessageService.insertBatchSystemMessage(systemMessage);

    }

    @Log(title = "系统消息通知", businessDesc = "删除群发消息")
    @ApiOperation(value = "删除群发消息（后台）", notes = "删除群发消息")
    @RequestMapping(value = "/deleteBatchSystemMessage", method = RequestMethod.POST)
    public ResponseResultVO deleteBatchSystemMessage(@RequestBody SystemMessageRO systemMessage) {
        return SystemMessageService.deleteBatchSystemMessage(systemMessage);
    }

    @ApiOperation(value = "给所有人发送websocket", notes = "给所有人发送websocket")
    @RequestMapping(value = "/sendWebsocketMessage", method = RequestMethod.GET)
    public ResponseResultVO sendWebsocketMessage(@RequestParam String content, @RequestParam(required = false) List<String> userIds) {
        return SystemMessageService.sendWebsocketMessage(content, userIds);
    }


}
